Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save justinbarry/80d58b0fc01b5be9916d15d904487eed to your computer and use it in GitHub Desktop.
Save justinbarry/80d58b0fc01b5be9916d15d904487eed to your computer and use it in GitHub Desktop.
API ideas
\\ 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