-
Notifications
You must be signed in to change notification settings - Fork 52
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
Feat: update typescript/app template to latest bindings #1855
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BaseEthereum } from "./wrap"; | ||
|
||
import { CoreClient, PolywrapClient } from "@polywrap/client-js"; | ||
|
||
export class Ethereum extends BaseEthereum { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As an app developer, it feels weird that I have to do this every time. I would imagine that the code below would be the "sane defaults", and if I wanted to change it I could do something like: import { Ethereum as DefaultEthereum } from "./wrap"
class Ethereum extends DefaultEthereum {
protected _getDefaultClient(): CoreClient {
// TODO: create your own custom client
}
} |
||
protected _getDefaultClient(): CoreClient { | ||
return new PolywrapClient(); | ||
} | ||
protected _getDefaultUri(): string | undefined { | ||
return undefined; | ||
} | ||
protected _getDefaultEnv(): Record<string, unknown> | undefined { | ||
return undefined; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,31 @@ | ||
import { | ||
Logging_Module, | ||
Ethereum_Module, | ||
} from "./wrap"; | ||
|
||
import { PolywrapClient } from "@polywrap/client-js"; | ||
|
||
const client = new PolywrapClient(); | ||
import { Ethereum } from "./ethereum"; | ||
import { Logger } from "./logger"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This would be npm wrap sdk |
||
async function main() { | ||
console.log("Invoking: Logging.info(...)"); | ||
|
||
await Logging_Module.info({ | ||
const logger = new Logger(); | ||
|
||
await logger.info({ | ||
message: "Hello there", | ||
}, client); | ||
}); | ||
|
||
await Logging_Module.info({ | ||
await logger.info({ | ||
message: "Hello again", | ||
}, client); | ||
}); | ||
|
||
await Logging_Module.info({ | ||
await logger.info({ | ||
message: "One last time...", | ||
}, client); | ||
}); | ||
|
||
console.log("Invoking: Ethereum.encodeParams(...)"); | ||
|
||
const result = await Ethereum_Module.encodeParams( | ||
{ | ||
types: ["address", "uint256"], | ||
values: ["0xB1B7586656116D546033e3bAFF69BFcD6592225E", "500"], | ||
}, | ||
client | ||
); | ||
const eth = new Ethereum(); | ||
|
||
const result = await eth.encodeParams({ | ||
types: ["address", "uint256"], | ||
values: ["0xB1B7586656116D546033e3bAFF69BFcD6592225E", "500"], | ||
}); | ||
|
||
if (result.ok) { | ||
console.log(`Ethereum.encodeParams:\n${result.value}`); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { BaseLogging } from "./wrap"; | ||
|
||
import { CoreClient, PolywrapClient } from "@polywrap/client-js"; | ||
|
||
export class Logger extends BaseLogging { | ||
protected _getDefaultClient(): CoreClient { | ||
return new PolywrapClient(); | ||
} | ||
protected _getDefaultUri(): string | undefined { | ||
return undefined; | ||
} | ||
protected _getDefaultEnv(): Record<string, unknown> | undefined { | ||
return undefined; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would go in npm sdk