Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rename app operator and clean up #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
```mermaid
sequenceDiagram
actor AppOperator
actor B3Admin
AppOperator->>AppRegistry: Register application
loop Every 2 weeks
B3Admin-->>PointsService: Grant points
AppOperator->>PointsService: Transfer points to users
end
```
Expand Down
6 changes: 3 additions & 3 deletions src/example/app/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {

dotenv.config(); // Load environment variables from .env file

const appModeratorPrivateKey =
`0x${process.env.MODERATOR_PRIVATE_KEY}` || `{0x}`;
const appOperatorPrivateKey =
`0x${process.env.OPERATOR_PRIVATE_KEY}` || `{0x}`;

export async function registerApp(): Promise<string> {
const registry = new AppRegistry(
Expand All @@ -26,7 +26,7 @@ export async function registerApp(): Promise<string> {
const resp = await registry.register(
"b3.b3.fun",
"0xB90d8162a3A1a2d760699F1f08c5F0cdAe1808F9",
privateKeyToAccount(<Hex>appModeratorPrivateKey),
privateKeyToAccount(<Hex>appOperatorPrivateKey),
);
return resp.toString();
}
Expand Down
31 changes: 0 additions & 31 deletions src/example/bps/advance-session.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/example/bps/cancel-transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {

dotenv.config(); // Load environment variables from .env file

const appModeratorPrivateKey =
`0x${process.env.MODERATOR_PRIVATE_KEY}` || `{0x}`;
const appOperatorPrivateKey =
`0x${process.env.OPERATOR_PRIVATE_KEY}` || `{0x}`;

export async function cancelTransfer(): Promise<string> {
const bps = new BPS(
Expand All @@ -25,7 +25,7 @@ export async function cancelTransfer(): Promise<string> {
bps.connect();
const response = await bps.cancelTransfer(
"0x123456", // replace with existing transfer uid
privateKeyToAccount(<Hex>appModeratorPrivateKey),
privateKeyToAccount(<Hex>appOperatorPrivateKey),
);
return response.toString();
}
Expand Down
38 changes: 0 additions & 38 deletions src/example/bps/grant-points.ts

This file was deleted.

6 changes: 3 additions & 3 deletions src/example/bps/transfer-points.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import {

dotenv.config(); // Load environment variables from .env file

const appModeratorPrivateKey =
`0x${process.env.MODERATOR_PRIVATE_KEY}` || `{0x}`;
const appOperatorPrivateKey =
`0x${process.env.OPERATOR_PRIVATE_KEY}` || `{0x}`;

export async function transferPoints(): Promise<string> {
const bps = new BPS(
Expand All @@ -31,7 +31,7 @@ export async function transferPoints(): Promise<string> {
point: 10n,
},
],
privateKeyToAccount(<Hex>appModeratorPrivateKey),
privateKeyToAccount(<Hex>appOperatorPrivateKey),
);
return response.toString();
}
Expand Down
26 changes: 7 additions & 19 deletions src/example/e2e/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import {

dotenv.config(); // Load environment variables from .env file

const appModeratorPrivateKey =
`0x${process.env.MODERATOR_PRIVATE_KEY}` || `{0x}`;
const b3AdminPrivateKey = `0x${process.env.B3_ADMIN_PRIVATE_KEY}` || `{0x}`;
const appOperatorPrivateKey =
`0x${process.env.OPERATOR_PRIVATE_KEY}` || `{0x}`;

const registry = new AppRegistry(
B3SepoliaPointIndexerURL,
Expand All @@ -37,8 +36,8 @@ async function main(): Promise<void> {
// register an app
let resp = await registry.register(
"test.b3.fun",
privateKeyToAccount(<Hex>appModeratorPrivateKey).address,
privateKeyToAccount(<Hex>appModeratorPrivateKey),
privateKeyToAccount(<Hex>appOperatorPrivateKey).address,
privateKeyToAccount(<Hex>appOperatorPrivateKey),
);
console.log("register-app:", resp);

Expand All @@ -52,28 +51,17 @@ async function main(): Promise<void> {
});
console.log("list-apps:", apps);

// grant points
resp = await bps.grantPoints(
[
{
appId: BigInt(apps.results.length > 0 ? apps.results[0].appId : 3n),
point: 20n,
},
],
privateKeyToAccount(<Hex>b3AdminPrivateKey),
);
console.log("grant-points:", resp);

// grant points
resp = await bps.transferPoints(
BigInt(apps.results.length > 0 ? apps.results[0].appId : 3n),
[
{
recipient: privateKeyToAccount(<Hex>appModeratorPrivateKey).address, // replace
recipient: privateKeyToAccount(<Hex>appOperatorPrivateKey).address, // replace
point: 20n,
},
],
privateKeyToAccount(<Hex>appModeratorPrivateKey),
privateKeyToAccount(<Hex>appOperatorPrivateKey),
);
console.log("transfer-points:", resp);

Expand All @@ -85,7 +73,7 @@ async function main(): Promise<void> {
console.log("appPoints:", appPoints);

const userPoints = await bps.getUserTotalPoints({
account: privateKeyToAccount(<Hex>appModeratorPrivateKey).address,
account: privateKeyToAccount(<Hex>appOperatorPrivateKey).address,
});
console.log("userPoints:", userPoints);
}
Expand Down