From aef8ad90db1e24628e7cb1f6e60c134bab4ea0aa Mon Sep 17 00:00:00 2001 From: subhod-i Date: Wed, 15 Jun 2022 13:21:03 +0530 Subject: [PATCH 1/2] docs(examples): make it v12 compatible --- examples/browser/aepp/src/StoreAeSdkPlugin.js | 8 +++---- examples/browser/wallet-iframe/src/App.vue | 23 +++++++++--------- .../wallet-web-extension/src/background.js | 24 +++++++++---------- examples/node/contract-interaction.js | 23 ++++++------------ .../node/paying-for-tx-contract-call-tx.js | 22 ++++++----------- examples/node/paying-for-tx-spend-tx.js | 18 ++++---------- examples/node/transfer-ae.js | 17 ++++--------- 7 files changed, 49 insertions(+), 86 deletions(-) diff --git a/examples/browser/aepp/src/StoreAeSdkPlugin.js b/examples/browser/aepp/src/StoreAeSdkPlugin.js index a9c46001c2..3f08996464 100644 --- a/examples/browser/aepp/src/StoreAeSdkPlugin.js +++ b/examples/browser/aepp/src/StoreAeSdkPlugin.js @@ -1,4 +1,4 @@ -import { RpcAepp, Node } from '@aeternity/aepp-sdk' +import { AeSdkAepp, Node } from '@aeternity/aepp-sdk' const TESTNET_NODE_URL = 'https://testnet.aeternity.io' const MAINNET_NODE_URL = 'https://mainnet.aeternity.io' @@ -31,15 +31,15 @@ export default (store) => { actions: { async initialize ({ commit }) { if (aeSdk) return - aeSdk = await RpcAepp({ + aeSdk = new AeSdkAepp({ name: 'Simple æpp', nodes: [ { name: 'testnet', instance: new Node(TESTNET_NODE_URL) }, { name: 'mainnet', instance: new Node(MAINNET_NODE_URL) } ], compilerUrl: COMPILER_URL, - onNetworkChange: ({ networkId }) => { - const [{ name }] = aeSdk.getNodesInPool() + onNetworkChange: async ({ networkId }) => { + const [{ name }] = (await aeSdk.getNodesInPool()) .filter(node => node.nodeNetworkId === networkId) aeSdk.selectNode(name) commit('setNetworkId', networkId) diff --git a/examples/browser/wallet-iframe/src/App.vue b/examples/browser/wallet-iframe/src/App.vue index 5f7eb015f1..88ecdc286b 100644 --- a/examples/browser/wallet-iframe/src/App.vue +++ b/examples/browser/wallet-iframe/src/App.vue @@ -29,7 +29,7 @@ @@ -87,4 +85,4 @@ xcode-select --install ``` ## Command Line Interface (CLI) -If you don't need to include specific functionality into your application and just want to use or play around with features the SDK provides you can make use of the [💻 CLI](https://github.com/aeternity/aepp-cli-js) and follow the instructions mentioned there. \ No newline at end of file +If you don't need to include specific functionality into your application and just want to use or play around with features the SDK provides you can make use of the [💻 CLI](https://github.com/aeternity/aepp-cli-js) and follow the instructions mentioned there. diff --git a/docs/quick-start.md b/docs/quick-start.md index 12cd3c0fef..d76032ea1e 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -2,11 +2,11 @@ In this example we will send 1 _AE_ coin from one account to another ## 1. Specify imports -For the following snippets in the guide you need to specify multiple imports. Most imports like `Universal`, `MemoryAccount` & `Node` are [Stamps](https://stampit.js.org/essentials/what-is-a-stamp) that compose certain functionalities. Others utility functions like `generateKeyPair` also can be imported. +For the following snippets in the guide you need to specify multiple imports. ```js const { - Universal, + AeSdk, MemoryAccount, Node, AE_AMOUNT_FORMATS, @@ -28,7 +28,7 @@ To receive some _AE_ you can use the [Faucet](https://faucet.aepps.com/). Just p ## 4. Interact with the æternity blockchain This example shows: -- how to create an instance of the SDK using the `Universal` [Stamp](https://stampit.js.org/essentials/what-is-a-stamp) +- how to create an instance of the SDK using the `Aesdk` class - how to spend (send) 1 AE from the account the SDK instance was initialized with to some other AE address ```js @@ -41,11 +41,12 @@ const senderAccount = new MemoryAccount({ (async function () { const node = new Node(NODE_URL) - const aeSdk = await Universal({ + const aeSdk = new AeSdk({ compilerUrl: COMPILER_URL, nodes: [{ name: 'testnet', instance: node }], - accounts: [senderAccount] }) + // Add sender account to the aeSdk state + await aeSdk.addAccount(senderAccount, { select: true }) // spend one AE await aeSdk.spend(1, '', { diff --git a/docs/transaction-options.md b/docs/transaction-options.md index 30c27dedaf..35bdf500eb 100644 --- a/docs/transaction-options.md +++ b/docs/transaction-options.md @@ -7,13 +7,13 @@ The `options` object can be optionally passed to the respective function behind const sender = 'ak_...' const recipient = 'ak_...' const options = { onAccount: sender, denomination: 'ae' } // optional options object -// aeSdk is an instance of the Universal Stamp +// aeSdk is an instance of the AeSdk class await aeSdk.spend(1, recipient, options) // amount, recipient and (optional) options ``` Note: -- Without the `options` object the sender would be the first account defined in the accounts array that is used to initialize the Universal Stamp and the recipient would receive `1 aetto` instead of `1 AE`. +- Without the `options` object the sender would be some other account selected in the instance of AeSdk and the recipient would receive `1 aetto` instead of `1 AE`. ## Common options These options are common and can be provided to every tx-type: diff --git a/docs/tutorials/vuejs/helloworld-blockheight.md b/docs/tutorials/vuejs/helloworld-blockheight.md index a1634d4387..f916718a83 100644 --- a/docs/tutorials/vuejs/helloworld-blockheight.md +++ b/docs/tutorials/vuejs/helloworld-blockheight.md @@ -27,7 +27,7 @@ npm install @aeternity/aepp-sdk