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

TypeChain #23

Closed
meherett opened this issue Jan 25, 2018 · 10 comments
Closed

TypeChain #23

meherett opened this issue Jan 25, 2018 · 10 comments

Comments

@meherett
Copy link

meherett commented Jan 25, 2018

How can we use TypeChain in angular 2+?

@pimotte
Copy link
Collaborator

pimotte commented Jan 25, 2018

Generating the code and refactoring the existing code starting around here: https://github.com/Quintor/angular-truffle-box/blob/master/src/app/meta/meta-sender/meta-sender.component.ts#L31 should be doable. The type of the MetaCoin would then be the specific contract, rather than any. I also tend to do the calls with .sendTransaction or .call explicitly, which I don't think the TypeChain library supports?

I'd be happy to accept a PR that does this cleanly. If I were to start working on it myself, I'll post it here.

@meherett
Copy link
Author

OK @pimotte,

Please!

I didn't understand meta-sender.component.ts, If i would like to give you sample smart contract so that give me an example of angular-truffle.

"pragma solidity ^0.4.8;
contract Storage {
uint256 storedData;
function set(uint256 data) {
storedData = data;
}
function get() constant returns (uint256) {
return storedData;
}
}"

Please! @pimotte

@pimotte
Copy link
Collaborator

pimotte commented Jan 25, 2018

https://github.com/Quintor/angular-truffle-box/blob/master/src/app/meta/meta-sender/meta-sender.component.ts#L63 and https://github.com/Quintor/angular-truffle-box/blob/master/src/app/meta/meta-sender/meta-sender.component.ts#L81 are the lines where the contract interaction happens. If you want to do that with TypeChain, you should end up with the needed object around those lines.

In general, using TypeChain with angular shouldn't be that different from using other libraries from angular, except maybe that the code is generated.

@meherett
Copy link
Author

meherett commented Jan 25, 2018

I am ok in typechain but i need this please

"pragma solidity ^0.4.8;
contract Storage {
uint256 storedData;
function set(uint256 data) {
storedData = data;
}
function get() constant returns (uint256) {
return storedData;
}
}"

web3.services.ts alwys contant i think

@pimotte
Copy link
Collaborator

pimotte commented Jan 25, 2018

If you want to implement an application that uses that contract, I recommend forking this repo and throwing away meta-sender.component.ts, and implement a new component that interacts with it.

This Truffle box already has the MetaCoin contract as an example, so an additional contract is not needed.

@meherett
Copy link
Author

meherett commented Jan 25, 2018

Error

Constructor: [object Object]
meta-sender.component.ts:28 OnInit: [object Object]
meta-sender.component.ts:29 MetaSenderComponent {web3Service: Web3Service, model: Object, status: ""}model: Objectstatus: ""web3Service: Web3Service__proto__: Object
core.js:3675 Angular is running in the development mode. Call enableProdMode() to enable the production mode.
core.js:1440 # ERROR TypeError: web3_1.default is not a constructor
at Web3Service.bootstrapWeb3 (web3.service.ts:26)
at eval (web3.service.ts:18)
at ZoneDelegate.invokeTask (zone.js:421)
at Object.onInvokeTask (core.js:4724)
at ZoneDelegate.invokeTask (zone.js:420)
at Zone.runTask (zone.js:188)
at ZoneTask.invokeTask [as invoke] (zone.js:496)
at invokeTask (zone.js:1517)
at globalZoneAwareCallback (zone.js:1543)
defaultErrorLogger @ core.js:1440
ErrorHandler.handleError @ core.js:1501
next @ core.js:5491
schedulerFn @ core.js:4319
SafeSubscriber.__tryOrUnsub @ Subscriber.js:240
SafeSubscriber.next @ Subscriber.js:187
Subscriber._next @ Subscriber.js:128
Subscriber.next @ Subscriber.js:92
Subject.next @ Subject.js:56
EventEmitter.emit @ core.js:4299
(anonymous) @ core.js:4755
ZoneDelegate.invoke @ zone.js:388
Zone.run @ zone.js:138
NgZone.runOutsideAngular @ core.js:4681
onHandleError @ core.js:4755
ZoneDelegate.handleError @ zone.js:392
Zone.runTask @ zone.js:191
ZoneTask.invokeTask @ zone.js:496
invokeTask @ zone.js:1517
globalZoneAwareCallback @ zone.js:1543

@pimotte
Copy link
Collaborator

pimotte commented Jan 25, 2018

Did you get any errors when installing dependencies?

@meherett
Copy link
Author

meherett commented Jan 25, 2018

"web3": "^1.0.0-beta.26"

it is not work for me then i install "web3": "^0.20.4" and this is work
but i get error https://github.com/Quintor/angular-truffle-box/blob/master/src/app/util/web3.service.ts#26

@meherett
Copy link
Author

meherett commented Jan 26, 2018

@pimotte
Copy link
Collaborator

pimotte commented Apr 2, 2018

If any of these issues still exist, feel free to create a new issue with a description how to reproduce them.

@pimotte pimotte closed this as completed Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants