Skip to content

Commit

Permalink
Support sending payments to muxed accounts (#173)
Browse files Browse the repository at this point in the history
* upgrading stellar-sdk and adding optional muxed acct support

* update TransactionBuilder to use new params
  • Loading branch information
piyalbasu authored and marcelosalloum committed Jul 19, 2021
1 parent 80e1343 commit 8c39c62
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"redux": "^4.0.5",
"stellar-sdk": "^8.0.0",
"stellar-sdk": "^8.2.1",
"styled-components": "^5.2.1",
"toml": "^3.0.0",
"typescript": "~4.1.3",
Expand Down
7 changes: 5 additions & 2 deletions src/methods/sep31Send/sendPayment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Account,
Asset,
BASE_FEE,
Keypair,
Expand Down Expand Up @@ -38,7 +39,9 @@ export const sendPayment = async ({
const keypair = Keypair.fromSecret(secretKey);
const server = new Server(networkUrl);
const asset = new Asset(assetCode, assetIssuer);
const account = await server.loadAccount(keypair.publicKey());
const publicKey = keypair.publicKey();
const account = await server.loadAccount(publicKey);
const { sequence } = await server.accounts().accountId(publicKey).call();

const accountBalance = account.balances.find(
(b: any) =>
Expand Down Expand Up @@ -77,7 +80,7 @@ export const sendPayment = async ({
);
}

const tx = new TransactionBuilder(account, {
const tx = new TransactionBuilder(new Account(publicKey, sequence), {
fee: (Number(BASE_FEE) * 5).toString(),
networkPassphrase,
})
Expand Down
1 change: 1 addition & 0 deletions src/methods/submitPaymentTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export const buildPaymentTransaction = async ({
destination,
asset,
amount: amount.toString(),
withMuxing: true,
});
} else {
log.instruction({
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11657,10 +11657,10 @@ stealthy-require@^1.1.1:
resolved "https://registry.yarnpkg.com/stealthy-require/-/stealthy-require-1.1.1.tgz#35b09875b4ff49f26a777e509b3090a3226bf24b"
integrity sha1-NbCYdbT/SfJqd35QmzCQoyJr8ks=

stellar-base@^4.0.3:
version "4.0.3"
resolved "https://registry.yarnpkg.com/stellar-base/-/stellar-base-4.0.3.tgz#03a55fd8ebbd32804d94e87f41bdc56af2a6747b"
integrity sha512-Tf1Ko86j4CgUtaiTC6H6qPZ97EziXN6SVokH4FGv5+XvBhFg4V+u9ySMlgPjFbHQumplkHiw8JQx1IZRHnrT3A==
stellar-base@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/stellar-base/-/stellar-base-5.2.1.tgz#d280d592793bbedeefdd3c92819299fc5bcc7897"
integrity sha512-hsooqL2EPSwCZeaWDEvPDc5KG6U68qOCdpdX5b1IA7oDwSjeJ7B/pxZYxSv6JkQNGhkfllNn2k7AyBVo4FR3Sw==
dependencies:
base32.js "^0.1.0"
bignumber.js "^4.0.0"
Expand All @@ -11672,10 +11672,10 @@ stellar-base@^4.0.3:
optionalDependencies:
sodium-native "^2.3.0"

stellar-sdk@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/stellar-sdk/-/stellar-sdk-8.0.0.tgz#5cba01b3a7bd874573d61effc618f9d9e697dde8"
integrity sha512-dguVMpBrd/tt2xr3JdOvSde5dYGTeL/FwfC9oOf45DIOC2uHse/kuUjyfknG2dWOXE1NqhHohZOvxAX2b+/BGg==
stellar-sdk@^8.2.1:
version "8.2.1"
resolved "https://registry.yarnpkg.com/stellar-sdk/-/stellar-sdk-8.2.1.tgz#c66e23db4879eabaf574abc26246b3b0b5627006"
integrity sha512-L1QFFWR27NE9QTi/lBfawHS13xKzfgqykEKN/vRQ9nYtV7cQilSj+aIYgDG5nVJEVzag+evQVMvl0QVerHOoOA==
dependencies:
"@types/eventsource" "^1.1.2"
"@types/node" ">= 8"
Expand All @@ -11688,7 +11688,7 @@ stellar-sdk@^8.0.0:
eventsource "^1.0.7"
lodash "^4.17.11"
randombytes "^2.1.0"
stellar-base "^4.0.3"
stellar-base "^5.2.1"
toml "^2.3.0"
tslib "^1.10.0"
urijs "^1.19.1"
Expand Down

0 comments on commit 8c39c62

Please sign in to comment.