-
-
Save justinbarry/80d58b0fc01b5be9916d15d904487eed to your computer and use it in GitHub Desktop.
API ideas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\\ Proposing this structure for getters and senders. | |
export interface Pong { | |
response: string; | |
} | |
export class Ping<TBigNumber> { | |
public static PingParams = t.type({}); | |
@Getter() | |
public static async ping<TBigNumber>(db: DB<TBigNumber>, params: t.TypeOf<typeof Ping.PingParams>): Promise<Pong> { | |
return { | |
response: "pong", | |
}; | |
} | |
@Sender() | |
public static async ping<TBigNumber>(provider: AugurProvider, params: t.TypeOf<typeof Ping.PingParams>): Promise<Pong> { | |
return provider.send(params.encode()); | |
} | |
} | |
\\ The provider is responsible for the following operations: | |
{ subscribe, unsubscribe, send, handleResponse, connect, disconnect } | |
Event handlers can have a similar format | |
export interface Pong { | |
response: string; | |
} | |
export class Ping<TBigNumber> { | |
public static PingParams = t.type({}); | |
@HandleEvent() | |
public static async ping<TBigNumber>(provider: AugurProvider, params: t.TypeOf<typeof Ping.PingParams>): Promise<Pong> { | |
return provider.send(params.encode()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment