Skip to content

Commit

Permalink
Use withdraw type if it is in the Asset (keybase#18695)
Browse files Browse the repository at this point in the history
* Add withdrawType

* Add withdraw type
  • Loading branch information
patrickxb authored Aug 2, 2019
1 parent 629ab13 commit 6eefc42
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions go/protocol/stellar1/common.go

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

7 changes: 6 additions & 1 deletion go/stellar/stellarsvc/anchor.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,14 @@ func (a *anchorInteractor) Withdraw(mctx libkb.MetaContext) (stellar1.AssetActio
return stellar1.AssetActionResultLocal{}, err
}

// TODO: `type` is supposedly optional, but actually required...so figure it out.
v := url.Values{}
v.Set("asset_code", a.asset.Code)
if a.asset.WithdrawType != "" {
// this is supposed to be optional, but a lot of anchors require it
// if they all change to optional, we can not return this from stellard
// and it won't get set
v.Set("type", a.asset.WithdrawType)
}
u.RawQuery = v.Encode()

var okResponse okWithdrawResponse
Expand Down
1 change: 1 addition & 0 deletions go/stellar/stellarsvc/anchor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ var validAnchorTests = []anchorTest{
Issuer: "GAKBPBDMW6CTRDCXNAPSVJZ6QAN3OBNRG6CWI27FGDQT2ZJJEMDRXPKK",
VerifiedDomain: "www.anchorusd.com",
TransferServer: "https://api.anchorusd.com/transfer",
WithdrawType: "bank_account",
},
DepositExternalURL: "https://portal.anchorusd.com/onboarding?account=GBZX4364PEPQTDICMIQDZ56K4T75QZCR4NBEYKO6PDRJAHZKGUOJPCXB&identifier=b700518e7430513abdbdab96e7ead566",
WithdrawExternalURL: "https://portal.anchorusd.com/onboarding?account=GACW7NONV43MZIFHCOKCQJAKSJSISSICFVUJ2C6EZIW5773OU3HD64VI",
Expand Down
1 change: 1 addition & 0 deletions protocol/avdl/stellar1/common.avdl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ protocol common {
string depositButtonText; // the text to show in the deposit button, most likely "Deposit"
boolean showWithdrawButton; // if true, show a withdraw button
string withdrawButtonText; // the text to show in the withdraw button, most likely "Withdraw"
string withdrawType; // bank_account, crypto, cash, etc. that the anchor supports
string transferServer; // sep6 transfer server
string authEndpoint; // sep6 auth endpoint
}
Expand Down
4 changes: 4 additions & 0 deletions protocol/json/stellar1/common.json

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

2 changes: 2 additions & 0 deletions shared/actions/wallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const emptyAsset: RPCStellarTypes.Asset = {
type: 'native',
verifiedDomain: '',
withdrawButtonText: '',
withdrawType: '',
}

const emptyAssetWithoutType: RPCStellarTypes.Asset = {
Expand Down Expand Up @@ -1234,6 +1235,7 @@ const assetDescriptionOrNativeToRpcAsset = (
type: asset === 'native' ? 'native' : asset.code.length > 4 ? 'credit_alphanum12' : 'credit_alphanum4',
verifiedDomain: asset === 'native' ? '' : asset.issuerVerifiedDomain,
withdrawButtonText: '',
withdrawType: '',
})

const rpcAssetToAssetDescriptionOrNative = (asset: RPCStellarTypes.Asset): Types.AssetDescriptionOrNative =>
Expand Down
2 changes: 1 addition & 1 deletion shared/constants/types/rpc-stellar-gen.tsx

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

1 change: 1 addition & 0 deletions shared/wallets/transaction-details/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const partialAsset = {
transferServer: '',
type: '',
withdrawButtonText: '',
withdrawType: '',
}

const load = () => {
Expand Down

0 comments on commit 6eefc42

Please sign in to comment.