OSDN Git Service

update the api return format and addup the error handle.
authorZhiting Lin <zlin035@uottawa.ca>
Tue, 4 Jun 2019 07:54:20 +0000 (15:54 +0800)
committerZhiting Lin <zlin035@uottawa.ca>
Tue, 4 Jun 2019 07:54:20 +0000 (15:54 +0800)
src/features/accounts/actions.js
src/sdk/api/accounts.js
src/sdk/api/transactions.js
src/sdk/connection.js

index 6936036..74eefd3 100644 (file)
@@ -24,7 +24,7 @@ let actions = {
     return chainClient().accounts.createAddress(data)
   },
   listAddresses: (accountId) => {
-    return chainClient().accounts.listAddresses(accountId)
+    return chainClient().accounts.listAddresses({accountId})
   }
 }
 
index c854111..ebe46a4 100644 (file)
@@ -33,7 +33,7 @@ const accountsAPI = (client) => {
 
     createReceiverBatch: (params, cb) => shared.createBatch(client, '/create-account-receiver', params, {cb}),
 
-    listAddresses: (accountId) => shared.query(client, 'accounts', '/list-addresses', {account_id: accountId}),
+    listAddresses: (params) => shared.query(client, 'accounts', '/list-addresses', params),
 
     validateAddresses: (address, cb) => shared.query(client, 'accounts', '/validate-address', {'address': address},  {cb})
   }
index 2a351fb..3106e61 100644 (file)
@@ -127,6 +127,11 @@ const transactionsAPI = (client) => {
             .then(resp => new shared.BatchResponse(resp)),
       cb
     ),
+
+    estimateGas: (template, cb) => shared.tryCallback(
+      client.request('/estimate-transaction-gas', {'transactionTemplate': template}).then(resp => checkForError(resp)),
+      cb
+    )
   }
 }
 
index d0dca98..f5ef2d2 100644 (file)
@@ -165,6 +165,9 @@ class Connection {
           }
         )
       }).then((body) => {
+        if(body.status === 'fail'){
+          throw body
+        }
         // After processing the response, convert snakecased field names to
         // camelcase to match language conventions.
         return skipSnakeize? body : camelize(body)