Skip to content

Commit

Permalink
fix: tx broadcast error msgs
Browse files Browse the repository at this point in the history
  • Loading branch information
yknl committed Oct 14, 2020
1 parent ad13e46 commit df60924
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
# # fallback to using the latest cache if no exact match is found
# - v1-dependencies-

- run: npx lerna bootstrap --hoist
- run: npx lerna bootstrap

# - save_cache:
# paths:
Expand Down
4 changes: 3 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
},
"dependencies": {
"@stacks/network": "^1.0.0-beta.4",
"@blockstack/stacks-transactions": "^v0.7.0",
"@stacks/transactions": "^1.0.0-beta.4",
"@stacks/auth": "^1.0.0-beta.4",
"@stacks/storage": "^1.0.0-beta.4",
"ajv": "^4.11.5",
"bip32": "^2.0.4",
"bip39": "^3.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { nameLookup, makeProfileJWT } from './utils';

import { CLINetworkAdapter } from './network';

import { GaiaHubConfig } from 'blockstack/lib/storage/hub';
import { GaiaHubConfig } from '@stacks/storage';

export const SIGNIN_CSS = `
h1 {
Expand Down
22 changes: 16 additions & 6 deletions packages/cli/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@ import {
PostConditionMode,
cvToString,
StacksTransaction,
} from '@blockstack/stacks-transactions';
TxBroadcastResult
} from '@stacks/transactions';

import { StacksMainnet, StacksTestnet } from '@stacks/network';

const c32check = require('c32check');

import { UserData } from 'blockstack/lib/auth/authApp';
import { UserData } from '@stacks/auth';

import { GaiaHubConfig } from 'blockstack/lib/storage/hub';
import { GaiaHubConfig } from '@stacks/storage';

import {
getOwnerKeyInfo,
Expand Down Expand Up @@ -555,7 +556,10 @@ async function sendTokens(network: CLINetworkAdapter, args: string[]): Promise<s
}

return broadcastTransaction(tx, txNetwork)
.then(() => {
.then((response: TxBroadcastResult) => {
if (response.hasOwnProperty('error')) {
return response;
}
return {
txid: tx.txid(),
transaction: generateExplorerTxPageUrl(tx.txid(), txNetwork),
Expand Down Expand Up @@ -611,7 +615,10 @@ async function contractDeploy(network: CLINetworkAdapter, args: string[]): Promi
}

return broadcastTransaction(tx, txNetwork)
.then(() => {
.then((response) => {
if (response.hasOwnProperty('error')) {
return response;
}
return {
txid: tx.txid(),
transaction: generateExplorerTxPageUrl(tx.txid(), txNetwork),
Expand Down Expand Up @@ -693,7 +700,10 @@ async function contractFunctionCall(network: CLINetworkAdapter, args: string[]):
}

return broadcastTransaction(tx, txNetwork)
.then(() => {
.then((response) => {
if (response.hasOwnProperty('error')) {
return response;
}
return {
txid: tx.txid(),
transaction: generateExplorerTxPageUrl(tx.txid(), txNetwork),
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {

import { CLINetworkAdapter, NameInfoType } from './network';

import { UserData } from 'blockstack/lib/auth/authApp';
import { UserData } from '@stacks/auth';

import { GaiaHubConfig } from 'blockstack/lib/storage/hub';
import { GaiaHubConfig, connectToGaiaHub } from '@stacks/storage';

/*
* Set up a session for Gaia.
Expand Down Expand Up @@ -101,6 +101,7 @@ export function gaiaAuth(
const authSessionToken = makeFakeAuthResponseToken(appPrivateKey, hubUrl, associationToken);
const nameLookupUrl = `${network.legacyNetwork.blockstackAPIUrl}/v1/names/`;
const transitPrivateKey = 'f33fb466154023aba2003c17158985aa6603db68db0f1afc0fcf1d641ea6c2cb'; // same as above
//@ts-ignore
return blockstack.handlePendingSignIn(nameLookupUrl, authSessionToken, transitPrivateKey);
}

Expand Down Expand Up @@ -128,8 +129,7 @@ export function gaiaConnect(
associationToken = makeAssociationToken(privateKey, ownerPrivateKey);
}

return blockstack
.connectToGaiaHub(gaiaHubUrl, canonicalPrivateKey(privateKey), associationToken)
return connectToGaiaHub(gaiaHubUrl, canonicalPrivateKey(privateKey), associationToken)
.then(hubConfig => {
// ensure that hubConfig always has a mainnet address, even if we're in testnet
if (network.coerceMainnetAddress(hubConfig.address) === addressMainnet) {
Expand Down
19 changes: 0 additions & 19 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -979,25 +979,6 @@
sha.js "^2.4.11"
smart-buffer "^4.1.0"

"@blockstack/stacks-transactions@^v0.7.0":
version "0.7.0"
resolved "https://registry.yarnpkg.com/@blockstack/stacks-transactions/-/stacks-transactions-0.7.0.tgz#c587f69879b1903bada87769f1d6d1217479336a"
integrity sha512-9IUR641PJpigYDCWdtKFgBIk0Oxyoc2M2XVdyaEOEcRhI+4lcacDhsuseAmGbkB9FhJgJcNicWPujUPNFl1XCw==
dependencies:
"@types/bn.js" "^4.11.6"
"@types/elliptic" "^6.4.12"
"@types/randombytes" "^2.0.0"
"@types/sha.js" "^2.4.0"
bn.js "^4.11.9"
c32check "^1.1.1"
cross-fetch "^3.0.5"
elliptic "^6.5.2"
lodash "^4.17.20"
randombytes "^2.1.0"
ripemd160-min "^0.0.6"
sha.js "^2.4.11"
smart-buffer "^4.1.0"

"@cnakazawa/watch@^1.0.3":
version "1.0.4"
resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a"
Expand Down

0 comments on commit df60924

Please sign in to comment.