Skip to content

Commit

Permalink
fix(subaccount-transfer): enforce senderAddress matches localWallet (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredvu authored Jun 20, 2024
1 parent 784194c commit a43f2a3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@cosmjs/proto-signing": "^0.32.1",
"@cosmjs/stargate": "^0.32.1",
"@cosmjs/tendermint-rpc": "^0.32.1",
"@dydxprotocol/v4-abacus": "^1.7.87",
"@dydxprotocol/v4-abacus": "1.7.90",
"@dydxprotocol/v4-client-js": "^1.1.20",
"@dydxprotocol/v4-localization": "^1.1.128",
"@ethersproject/providers": "^5.7.2",
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

13 changes: 9 additions & 4 deletions src/lib/abacus/dydxChainTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -552,16 +552,21 @@ class DydxChainTransactions implements AbacusDYDXChainTransactionsProtocol {
}

async subaccountTransfer(params: {
senderAddress: string;
subaccountNumber: number;
amount: string;
destinationAddress: string;
destinationSubaccountNumber: number;
}): Promise<string> {
if (!this.compositeClient || !this.localWallet) {
throw new Error('Missing compositeClient or localWallet');
}

try {
if (!this.compositeClient || !this.localWallet) {
throw new Error('Missing compositeClient or localWallet');
}

if (params.senderAddress !== this.localWallet.address) {
throw new Error('Sender address does not match local wallet');
}

const tx = await this.compositeClient.transferToSubaccount(
new SubaccountClient(this.localWallet, params.subaccountNumber),
params.destinationAddress,
Expand Down

0 comments on commit a43f2a3

Please sign in to comment.