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

Improve compatibility with create-react-app #1409

Merged
merged 3 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions babel.esm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ config.presets

config.plugins.push(
['add-import-extension', { extension: 'mjs' }],
['import-globals', {
Buffer: { moduleName: 'buffer', exportName: 'Buffer' }
}],
['transform-default-named-imports', { exclude: ['rlp'] }]
)

Expand Down
38 changes: 36 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"@aeternity/argon2-browser": "^0.1.1",
"@aeternity/bip39": "^0.1.0",
"@aeternity/json-bigint": "^0.3.1",
"@aeternity/uuid": "^0.0.1",
"@babel/runtime-corejs3": "^7.16.8",
"@stamp/it": "^1.1.0",
"@stamp/required": "^1.0.1",
Expand All @@ -56,7 +57,6 @@
"swagger-client": "^3.18.2",
"tweetnacl": "^1.0.3",
"tweetnacl-auth": "^1.0.1",
"uuid": "^8.3.2",
"websocket": "^1.0.34"
},
"repository": {
Expand All @@ -81,6 +81,7 @@
"@typescript-eslint/parser": "^5.10.1",
"babel-loader": "^8.2.3",
"babel-plugin-add-import-extension": "^1.6.0",
"babel-plugin-import-globals": "^2.0.0",
"babel-plugin-transform-default-named-imports": "^1.2.2",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
import stampit from '@stamp/it'
import WalletConnection from '.'
import { v4 as uuid } from 'uuid'
import { v4 as uuid } from '@aeternity/uuid'
import { MESSAGE_DIRECTION } from '../schema'
import { getBrowserAPI, isInIframe } from '../helpers'
import {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/aepp-wallet-communication/rpc/aepp-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* import ContentScriptBridge
* from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/aepp-rpc'
*/
import { v4 as uuid } from 'uuid'
import { v4 as uuid } from '@aeternity/uuid'
import Ae from '../../../ae'
import RpcClient from './rpc-client'
import { getHandler, message, voidFn } from '../helpers'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/aepp-wallet-communication/rpc/wallet-rpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @example
* import WalletRpc from '@aeternity/aepp-sdk/es/utils/aepp-wallet-communication/rpc/wallet-rpc'
*/
import { v4 as uuid } from 'uuid'
import { v4 as uuid } from '@aeternity/uuid'
import Ae from '../../../ae'
import verifyTransaction from '../../../tx/validator'
import AccountMultiple from '../../../account/multiple'
Expand Down
2 changes: 1 addition & 1 deletion src/utils/keystore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import nacl from 'tweetnacl'
import { v4 as uuid } from 'uuid'
import { v4 as uuid } from '@aeternity/uuid'
import { ArgonType, hash } from '@aeternity/argon2-browser/dist/argon2-bundled.min.js'
import { encodeBase58Check } from './crypto'
import { str2buf } from './bytes'
Expand Down
31 changes: 31 additions & 0 deletions test/environment/node.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Node, Universal, MemoryAccount } from '../../es/index.mjs'

const contractSource = `
contract Test =
entrypoint getArg(x : map(string, int)) = x
`;

(async () => {
const node = await Node({ url: 'https://testnet.aeternity.io' })
const sdk = await Universal({
nodes: [{ name: 'testnet', instance: node }],
compilerUrl: 'https://compiler.aepps.com',
accounts: [MemoryAccount({
keypair: {
publicKey: 'ak_2dATVcZ9KJU5a8hdsVtTv21pYiGWiPbmVcU1Pz72FFqpk9pSRR',
secretKey: 'bf66e1c256931870908a649572ed0257876bb84e3cdf71efb12f56c7335fad54d5cf08400e988222f26eb4b02c8f89077457467211a6e6d955edb70749c6a33b'
}
})]
})

console.log('Height:', await sdk.height())
console.log('Instanceof works correctly for nodes pool', sdk.pool instanceof Map)

const contract = await sdk.getContractInstance({ source: contractSource })
const deployInfo = await contract.deploy()
console.log('Contract deployed at', deployInfo.address)
const map = new Map([['foo', 42], ['bar', 43]])
const { decodedResult } = await contract.methods.getArg(map)
console.log('Call result', decodedResult)
console.log('Instanceof works correctly for returned map', decodedResult instanceof Map)
})()