Skip to content

Commit

Permalink
Merge pull request #535 from stellar/il-muxed-accounts-dynamic-flag
Browse files Browse the repository at this point in the history
Set withMuxing flags dynamically
  • Loading branch information
quietbits authored Jun 30, 2021
2 parents ee23c76 + 8e3012e commit 5d92e57
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 41 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"@babel/preset-env": "^7.6.2",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.6.2",
"@ledgerhq/hw-app-str": "^5.49.0",
"@ledgerhq/hw-transport-webusb": "^5.49.0",
"@ledgerhq/hw-app-str": "^6.0.2",
"@ledgerhq/hw-transport-webusb": "^6.0.2",
"@stellar/freighter-api": "1.0.1",
"@stellar/prettier-config": "^1.0.1",
"axios": "^0.21.1",
Expand Down
14 changes: 8 additions & 6 deletions src/utilities/Libify.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import isString from 'lodash/isString';
import isUndefined from 'lodash/isUndefined';
import map from 'lodash/map';
import { createPredicate } from "../utilities/claimantHelpers";
import isValidMAddress from "../utilities/isValidMAddress"

// Helpers
let isInt = function(value) {
Expand Down Expand Up @@ -140,7 +141,7 @@ Libify.Operation.payment = function(opts) {
asset: Libify.Asset(opts.asset),
amount: opts.amount,
source: opts.sourceAccount,
withMuxing: true,
withMuxing: isValidMAddress(opts.destination),
})
}

Expand All @@ -166,7 +167,7 @@ Libify.Operation.pathPaymentStrictSend = function(opts) {
destMin: opts.destMin,
path: libifiedPath,
source: opts.sourceAccount,
withMuxing: true,
withMuxing: isValidMAddress(opts.destination),
})
}

Expand All @@ -192,7 +193,7 @@ Libify.Operation.pathPaymentStrictReceive = function(opts) {
destAmount: opts.destAmount,
path: libifiedPath,
source: opts.sourceAccount,
withMuxing: true,
withMuxing: isValidMAddress(opts.destination),
})
}

Expand Down Expand Up @@ -223,7 +224,7 @@ Libify.Operation.accountMerge = function(opts) {
return Sdk.Operation.accountMerge({
destination: opts.destination,
source: opts.sourceAccount,
withMuxing: true,
withMuxing: isValidMAddress(opts.destination),
})
}

Expand Down Expand Up @@ -537,16 +538,17 @@ Libify.buildTransaction = function(attributes, operations, networkPassphrase) {
try {
let account;
const sequence = Sdk.UnsignedHyper.fromString(attributes.sequence).subtract(1).toString();
const isMAddress = isValidMAddress(attributes.sourceAccount);

if (attributes.sourceAccount.startsWith("M")) {
if (isMAddress) {
account = new Sdk.MuxedAccount.fromAddress(attributes.sourceAccount, sequence);
} else {
account = new Sdk.Account(attributes.sourceAccount, sequence);
}

let opts = {
networkPassphrase,
withMuxing: true,
withMuxing: isMAddress,
};
if (attributes.fee !== '') {
const MAX_UINT32 = Math.pow( 2, 32 ) - 1;
Expand Down
66 changes: 33 additions & 33 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -893,54 +893,54 @@
"@babel/helper-validator-identifier" "^7.12.11"
to-fast-properties "^2.0.0"

"@ledgerhq/devices@^5.51.1":
version "5.51.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-5.51.1.tgz#d741a4a5d8f17c2f9d282fd27147e6fe1999edb7"
integrity sha512-4w+P0VkbjzEXC7kv8T1GJ/9AVaP9I6uasMZ/JcdwZBS3qwvKo5A5z9uGhP5c7TvItzcmPb44b5Mw2kT+WjUuAA==
"@ledgerhq/devices@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/devices/-/devices-6.0.2.tgz#cbf730368f00ddb5a4384f73bb4966371aa2a4c3"
integrity sha512-xR4RYXltXISH4Vf7bLgiaIRy4W3F+kvDXYhXY7Q72goR4NA+vAosuRLGFQZIQiuZZMdPCIbXHuysj07z/NsEpA==
dependencies:
"@ledgerhq/errors" "^5.50.0"
"@ledgerhq/logs" "^5.50.0"
"@ledgerhq/errors" "^6.0.2"
"@ledgerhq/logs" "^6.0.2"
rxjs "6"
semver "^7.3.5"

"@ledgerhq/errors@^5.50.0":
version "5.50.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-5.50.0.tgz#e3a6834cb8c19346efca214c1af84ed28e69dad9"
integrity sha512-gu6aJ/BHuRlpU7kgVpy2vcYk6atjB4iauP2ymF7Gk0ez0Y/6VSMVSJvubeEQN+IV60+OBK0JgeIZG7OiHaw8ow==
"@ledgerhq/errors@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/errors/-/errors-6.0.2.tgz#7c88d16620db08c96de6a2636440db1c0e541da1"
integrity sha512-m42ZMzR/EKpOrZfPR3DzusE98DoF3d03cbBkQG6ddm6diwVXFSa7MabaKzgD+41EYQ+hrCGOEZK1K0kosX1itg==

"@ledgerhq/hw-app-str@^5.49.0":
version "5.51.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-str/-/hw-app-str-5.51.1.tgz#af480c020a0c3383d674a20c115f291fcbd4029e"
integrity sha512-Cr5iJTS2LEWe7gR0NLJai66kS2s7Lwf6NfdUmp7O2ln84lFOKfkLGzgiJcOvIPMlfATRNLF45ow8B1s637Gdeg==
"@ledgerhq/hw-app-str@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-app-str/-/hw-app-str-6.0.2.tgz#dfbd0c67acdd09befd24661c06bd632cd927f342"
integrity sha512-+VSIZzeJ7F9pU19TH74XjrjUYoGLYQ9DS1s9bGCvCep0Vd061dtXZwNhmnu7gWYKRHvLkEEMDZQHdARByHqR0w==
dependencies:
"@ledgerhq/hw-transport" "^5.51.1"
"@ledgerhq/hw-transport" "^6.0.2"
base32.js "^0.1.0"
sha.js "^2.3.6"
tweetnacl "^1.0.3"

"@ledgerhq/hw-transport-webusb@^5.49.0":
version "5.53.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-webusb/-/hw-transport-webusb-5.53.1.tgz#3df8c401417571e3bcacc378d8aca587214b05ae"
integrity sha512-A/f+xcrkIAZiJrvPpDvsrjxQX4cI2kbdiunQkwsYmOG3Bp4z89ZnsBiC7YBst4n2/g+QgTg0/KPVtODU5djooQ==
"@ledgerhq/hw-transport-webusb@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport-webusb/-/hw-transport-webusb-6.0.2.tgz#d479e854ac8fd5051b7a6544146a96128b63d9a4"
integrity sha512-eSYKzj4RvRMY6pcOvCECVyVXtjUiTtYr1S51fGdRy9bwS51DlLujyKAQb+gKM8aWJHAN0FRgiwUaQLsYETd1eg==
dependencies:
"@ledgerhq/devices" "^5.51.1"
"@ledgerhq/errors" "^5.50.0"
"@ledgerhq/hw-transport" "^5.51.1"
"@ledgerhq/logs" "^5.50.0"
"@ledgerhq/devices" "^6.0.2"
"@ledgerhq/errors" "^6.0.2"
"@ledgerhq/hw-transport" "^6.0.2"
"@ledgerhq/logs" "^6.0.2"

"@ledgerhq/hw-transport@^5.51.1":
version "5.51.1"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-5.51.1.tgz#8dd14a8e58cbee4df0c29eaeef983a79f5f22578"
integrity sha512-6wDYdbWrw9VwHIcoDnqWBaDFyviyjZWv6H9vz9Vyhe4Qd7TIFmbTl/eWs6hZvtZBza9K8y7zD8ChHwRI4s9tSw==
"@ledgerhq/hw-transport@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/hw-transport/-/hw-transport-6.0.2.tgz#5b3a0cb01eb6adbd876916bc7d566226e505d333"
integrity sha512-JI8bhs0vQW1pjDeZ8/Cv/OT4iejH2F3j0i5z5mGNkSgs179GiGeM81EhStLB0XuXqxWpFZMnZ97/Cdo0XmffrA==
dependencies:
"@ledgerhq/devices" "^5.51.1"
"@ledgerhq/errors" "^5.50.0"
"@ledgerhq/devices" "^6.0.2"
"@ledgerhq/errors" "^6.0.2"
events "^3.3.0"

"@ledgerhq/logs@^5.50.0":
version "5.50.0"
resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-5.50.0.tgz#29c6419e8379d496ab6d0426eadf3c4d100cd186"
integrity sha512-swKHYCOZUGyVt4ge0u8a7AwNcA//h4nx5wIi0sruGye1IJ5Cva0GyK9L2/WdX+kWVTKp92ZiEo1df31lrWGPgA==
"@ledgerhq/logs@^6.0.2":
version "6.0.2"
resolved "https://registry.yarnpkg.com/@ledgerhq/logs/-/logs-6.0.2.tgz#a6063ed99461c0d2c36a48de89ed0283f13cb908"
integrity sha512-4lU3WBwugG+I/dv/qE8HQ2f7MNsKfU58FEzSE1PAELvW96umrlO4ogwuO1tRCPmrtOo9ssam1QVYotwELY8zvw==

"@stellar/[email protected]":
version "1.0.1"
Expand Down

0 comments on commit 5d92e57

Please sign in to comment.