@@ -5,13 +5,10 @@ import {
55 InMemoryTransactionSender ,
66 StateServiceQueryModule ,
77} from "@proto-kit/sdk" ;
8- import { PrivateKey , PublicKey } from "o1js" ;
9- import { Runtime , runtimeMethod , runtimeModule } from "@proto-kit/module" ;
10- import { Protocol , State , state } from "@proto-kit/protocol" ;
8+ import { PrivateKey } from "o1js" ;
9+ import { Runtime } from "@proto-kit/module" ;
10+ import { Protocol } from "@proto-kit/protocol" ;
1111import {
12- Balance ,
13- Balances ,
14- BalancesKey ,
1512 TokenId ,
1613 VanillaProtocolModules ,
1714 VanillaRuntimeModules ,
@@ -44,42 +41,7 @@ import {
4441} from "@proto-kit/api" ;
4542import { container } from "tsyringe" ;
4643
47- @runtimeModule ( )
48- export class TestBalances extends Balances {
49- /**
50- * We use `satisfies` here in order to be able to access
51- * presets by key in a type safe way.
52- */
53- // public static presets = {} satisfies Presets<object>;
54-
55- @state ( ) public totalSupply = State . from < UInt64 > ( UInt64 ) ;
56-
57- @runtimeMethod ( )
58- public async getBalanceForUser (
59- tokenId : TokenId ,
60- address : PublicKey
61- ) : Promise < Balance > {
62- return await super . getBalance ( tokenId , address ) ;
63- }
64-
65- @runtimeMethod ( )
66- public async addBalance (
67- tokenId : TokenId ,
68- address : PublicKey ,
69- balance : UInt64
70- ) {
71- const totalSupply = await this . totalSupply . get ( ) ;
72- await this . totalSupply . set ( totalSupply . orElse ( UInt64 . zero ) . add ( balance ) ) ;
73-
74- const previous = await this . balances . get (
75- new BalancesKey ( { tokenId, address } )
76- ) ;
77- await this . balances . set (
78- new BalancesKey ( { tokenId, address } ) ,
79- previous . orElse ( UInt64 . zero ) . add ( balance )
80- ) ;
81- }
82- }
44+ import { TestBalances } from "../../helpers/TestBalance" ;
8345
8446export async function startServer ( ) {
8547 log . setLevel ( "DEBUG" ) ;
0 commit comments