However I am getting: Uncaught (in promise): TypeError: Cannot read property ‘publicKey’ of undefined
The error shouts when trying to assign MemmoryAccount to accounts property in the passed object, however i dont believe the problem is with sdk as, the same approach is used in Vue/React boilerplates and it works like a charm.
The root cause of this problem is that Angular seems to be not providing polyfills by default for some types, where React and Vue do.
So what solves the problem is:
Installing these 2 packages to the Angular project:
npm install buffer --save
npm install process --save
And adding the following to the polyfill.ts:
// process is not defined
import * as process from 'process';
window['process'] = process;
// buffer is not defined
window.Buffer = window.Buffer || require('buffer').Buffer;
I’ll try to ask around for a more elegant way to solve this issue for good
A quick pointer to the JS SDK team: What made debugging take time here was the fact the corresponding error was silenced in node_modules/@aeternity/aepp-sdk/es/account/memory.js with the elegant comment:
... } catch (e) {
// Instead of throw error and crash show warning that you do not set `KEYPAIR`
// and can not sign transaction
console.log('Please provide KEY_PAIR for sign transaction') }
please don’t silence errors without prior evaluation guys, sometimes they arise for different reasons than missing params (cc: @shekhar-shubhendu@noandrea)
Can you show me how do you import sdk into your app?
If you are using bundle import { Universal } from '@aeternity/aepp-sdk' then it must work
If you are using tree-shaking import { Universal } from '@aeternity/aepp-sdk/es' the you need to handle polyfills on your side.