Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@blockedprotocol/points-sdk

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blockedprotocol/points-sdk - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

29

dist/index.d.ts
import { CreateTRPCClient } from '@trpc/client';
import * as _trpc_server from '@trpc/server';
import * as _trpc_server_unstable_core_do_not_import from '@trpc/server/unstable-core-do-not-import';

@@ -31,3 +32,3 @@ import * as _prisma_client_runtime_library from '@prisma/client/runtime/library';

}, {
getPoints: _trpc_server_unstable_core_do_not_import.QueryProcedure<{
getPoints: _trpc_server.TRPCQueryProcedure<{
input: {

@@ -40,3 +41,3 @@ account: string;

}>;
getPointsForUser: _trpc_server_unstable_core_do_not_import.QueryProcedure<{
getPointsForUser: _trpc_server.TRPCQueryProcedure<{
input: {

@@ -49,3 +50,3 @@ userId: string;

}>;
getLeaderboard: _trpc_server_unstable_core_do_not_import.QueryProcedure<{
getLeaderboard: _trpc_server.TRPCQueryProcedure<{
input: void;

@@ -57,3 +58,3 @@ output: {

}>;
getLeaderboardRank: _trpc_server_unstable_core_do_not_import.QueryProcedure<{
getLeaderboardRank: _trpc_server.TRPCQueryProcedure<{
input: {

@@ -67,3 +68,3 @@ account: string;

}>;
track: _trpc_server_unstable_core_do_not_import.MutationProcedure<{
track: _trpc_server.TRPCMutationProcedure<{
input: {

@@ -79,3 +80,3 @@ account: string;

}>;
getEvents: _trpc_server_unstable_core_do_not_import.QueryProcedure<{
getEvents: _trpc_server.TRPCQueryProcedure<{
input: {

@@ -103,3 +104,3 @@ account: string;

}, {
findByAccount: _trpc_server_unstable_core_do_not_import.QueryProcedure<{
findByAccount: _trpc_server.TRPCQueryProcedure<{
input: {

@@ -110,10 +111,12 @@ account: string;

}>;
create: _trpc_server_unstable_core_do_not_import.MutationProcedure<{
create: _trpc_server.TRPCMutationProcedure<{
input: {
accounts: string[];
referredByUser?: string | undefined;
params?: {
referredByUser?: string | undefined;
} | undefined;
};
output: User;
}>;
linkAccounts: _trpc_server_unstable_core_do_not_import.MutationProcedure<{
linkAccounts: _trpc_server.TRPCMutationProcedure<{
input: {

@@ -136,7 +139,9 @@ userId: string;

}>;
create(accounts: string[], referredByUser?: string): Promise<{
create(accounts: string[], params?: {
referredByUser?: string;
}): Promise<{
id: string;
accounts: string[];
}>;
linkWallets(userId: string, accounts: string[]): Promise<never>;
linkAccounts(userId: string, accounts: string[]): Promise<never>;
}

@@ -143,0 +148,0 @@

@@ -12,9 +12,9 @@ // src/index.ts

}
async create(accounts, referredByUser) {
async create(accounts, params) {
return this.trpc.users.create.mutate({
accounts,
referredByUser
params
});
}
async linkWallets(userId, accounts) {
async linkAccounts(userId, accounts) {
return this.trpc.users.linkAccounts.mutate({

@@ -21,0 +21,0 @@ userId,

{
"name": "@blockedprotocol/points-sdk",
"version": "0.0.3",
"version": "0.0.4",
"description": "",

@@ -19,9 +19,9 @@ "type": "module",

"devDependencies": {
"@types/node": "^20.12.5",
"@types/node": "^20.12.7",
"tsup": "^8.0.2",
"typescript": "^5.4.3"
"typescript": "^5.4.5"
},
"dependencies": {
"@trpc/client": "^11.0.0-rc.330"
"@trpc/client": "^11.0.0-rc.342"
}
}

@@ -11,2 +11,3 @@ # Blocked Points SDK

- Use meaningful event names that clearly describe the action being performed.
- Use a maximum of 4 digits after the decimal point for your points.

@@ -57,3 +58,5 @@ ## Get Started

### Substract points
You can substract points for account using the negative value. The following example will decrement 50 points:
```ts

@@ -66,2 +69,13 @@ await blockedSdk.points.track("penalty", {

### Multiply points
You can multiply points. The following example will multiply points by 1.5:
```ts
await blockedSdk.points.track("top_user", {
account: "11111111111111111111111111111111",
multiplicator: 1.5,
});
```
### Get points for an account

@@ -104,2 +118,3 @@

### Get events
Get the events for a specific event name using the getEvents method.

@@ -130,21 +145,44 @@

Here's how you can create user:
```ts
await blockedSdk.users.create([
"11111111111111111111111111111111",
"22222222222222222222222222222222",
]);
await blockedSdk.users.create(["11111111111111111111111111111111"]);
// => { id: "<USER_ID>" }
```
### Create user and add referrer
Note: if account already linked to another user, error will be thrown.
### Create user with referrer
If you know that account `A` has referred account `B`, you can create a user entity and provide the referral information.
Follow the code snippet to create user and specify referrer:
```ts
const referrerUser = blockedSdk.users.findByAccount(
"22222222222222222222222222222222"
);
await blockedSdk.users.create(["11111111111111111111111111111111"], referrerUser.id);
// 1. find referrer user
// if user doesn't exist for account, error will be thrown
// see step above on how to create user without referrer
const referrerUser = blockedSdk.users.findByAccount("A");
// 2. create user
await blockedSdk.users.create(["B"], referrerUser.id);
// => { id: "<USER_ID>" }
```
As a result you craeted user `B` referred by user `A`.
### Link multiple wallets to user
You can link accounts to a user even after user entity was created.
If you know that user with account `abc` has also accounts `aaa` and `bbb`.
```ts
// 1. Find user with account `abc`
// if user doesn't exist for account, error will be thrown
// see step above on how to create user
const user = await blockedApi.users.findByAccount("abc");
// 2. Link accounts `aaa` and `bbb` to the same user
await blockedApi.users.linkAccounts(user.id, ["aaa", "bbb"]);
```
### Get points for user

@@ -151,0 +189,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc