Skip to content

Commit 95bb0b0

Browse files
authored
Merge pull request #8100 from BitGo/WIN-8912-allow-valueless-transfers-for-hash
feat(hash): allow valueless transactions
2 parents 2690e00 + e165565 commit 95bb0b0

File tree

8 files changed

+51
-14
lines changed

8 files changed

+51
-14
lines changed

modules/sdk-coin-atom/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
"@bitgo/sdk-api": "^1.73.4",
5454
"@bitgo/sdk-test": "^9.1.25",
5555
"@types/lodash": "^4.14.183",
56-
"axios": "^1.12.0"
56+
"axios": "^1.13.0"
5757
},
5858
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c",
5959
"files": [

modules/sdk-coin-hash/src/hash.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,9 @@ export class Hash extends CosmosCoin {
6565
getAddressFromPublicKey(publicKey: string): string {
6666
return new KeyPair({ pub: publicKey }).getAddress(AddressFormat.mainnet);
6767
}
68+
69+
/** @inheritDoc **/
70+
valuelessTransferAllowed(): boolean {
71+
return true;
72+
}
6873
}

modules/sdk-coin-hash/src/lib/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class HashUtils extends CosmosUtils {
3838
/** @inheritdoc */
3939
validateAmount(amount: Coin): void {
4040
const amountBig = BigNumber(amount.amount);
41-
if (amountBig.isLessThanOrEqualTo(0)) {
41+
if (amountBig.isLessThan(0)) {
4242
throw new InvalidTransactionError('transactionBuilder: validateAmount: Invalid amount: ' + amount.amount);
4343
}
4444
if (!constants.validDenoms.find((denom) => denom === amount.denom)) {

modules/sdk-coin-hash/test/unit/transactionBuilder/transferBuilder.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,38 @@ describe('Hash Transfer Builder', () => {
124124
]);
125125
});
126126

127+
it('should build a transfer tx of zero amount without signature', async function () {
128+
const zeroAmountTx = JSON.parse(JSON.stringify(testTx));
129+
zeroAmountTx.sendMessage.value.amount[0].amount = '0';
130+
const txBuilder = factory.getTransferBuilder();
131+
txBuilder.sequence(zeroAmountTx.sequence);
132+
txBuilder.gasBudget(zeroAmountTx.gasBudget);
133+
txBuilder.messages([zeroAmountTx.sendMessage.value]);
134+
txBuilder.publicKey(toHex(fromBase64(zeroAmountTx.pubKey)));
135+
const tx = await txBuilder.build();
136+
const json = await (await txBuilder.build()).toJson();
137+
should.equal(tx.type, TransactionType.Send);
138+
should.deepEqual(json.gasBudget, zeroAmountTx.gasBudget);
139+
should.deepEqual(json.sendMessages, [zeroAmountTx.sendMessage]);
140+
should.deepEqual(json.publicKey, toHex(fromBase64(zeroAmountTx.pubKey)));
141+
should.deepEqual(json.sequence, zeroAmountTx.sequence);
142+
tx.toBroadcastFormat();
143+
should.deepEqual(tx.inputs, [
144+
{
145+
address: testData.TEST_SEND_TX.sender,
146+
value: '0',
147+
coin: basecoin.getChain(),
148+
},
149+
]);
150+
should.deepEqual(tx.outputs, [
151+
{
152+
address: testData.TEST_SEND_TX.sendMessage.value.toAddress,
153+
value: '0',
154+
coin: basecoin.getChain(),
155+
},
156+
]);
157+
});
158+
127159
it('should sign a Transfer tx', async function () {
128160
const txBuilder = factory.getTransferBuilder();
129161
txBuilder.sequence(testTx.sequence);

modules/sdk-coin-sui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@bitgo/sdk-api": "^1.73.4",
5757
"@bitgo/sdk-test": "^9.1.25",
5858
"@types/lodash": "^4.14.183",
59-
"axios": "^1.12.0",
59+
"axios": "^1.13.0",
6060
"debug": "^4.3.4"
6161
},
6262
"gitHead": "18e460ddf02de2dbf13c2aa243478188fb539f0c",

modules/utxo-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"devDependencies": {
6363
"@types/fs-extra": "^9.0.12",
6464
"@types/node": "^24.10.9",
65-
"axios": "^1.12.0",
65+
"axios": "^1.13.0",
6666
"debug": "^3.1.0",
6767
"fs-extra": "^9.1.0"
6868
},

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
"@polkadot/api": "14.1.1",
9797
"elliptic": "^6.6.1",
9898
"cookie": "^0.7.1",
99-
"axios": "^1.12.0",
99+
"axios": "^1.13.0",
100100
"canvg": "4.0.3",
101101
"**/stellar-sdk/**/bignumber.js": "4.1.0",
102102
"**/stellar-base/**/bignumber.js": "4.1.0",
@@ -155,7 +155,7 @@
155155
"test:prepare-release": "mocha --require tsx ./scripts/tests/prepareRelease/prepare-release-main.test.ts"
156156
},
157157
"dependencies": {
158-
"axios": "^1.12.0",
158+
"axios": "^1.13.0",
159159
"terser": "^5.14.2",
160160
"tmp": "^0.2.3",
161161
"bigint-buffer": "npm:@trufflesuite/bigint-buffer@1.1.10"

yarn.lock

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7666,13 +7666,13 @@ aws4@^1.8.0:
76667666
resolved "https://registry.npmjs.org/aws4/-/aws4-1.13.2.tgz"
76677667
integrity sha512-lHe62zvbTB5eEABUVi/AwVh0ZKY9rMMDhmm+eeyuuUQbQ3+J+fONVQOZyj+DdrvD4BY33uYniyRJ4UJIaSKAfw==
76687668

7669-
axios@0.25.0, axios@0.27.2, axios@1.7.4, axios@^0.21.2, axios@^0.26.1, axios@^1.12.0, axios@^1.6.0, axios@^1.8.3:
7670-
version "1.12.1"
7671-
resolved "https://registry.npmjs.org/axios/-/axios-1.12.1.tgz"
7672-
integrity sha512-Kn4kbSXpkFHCGE6rBFNwIv0GQs4AvDT80jlveJDKFxjbTYMUeB4QtsdPCv6H8Cm19Je7IU6VFtRl2zWZI0rudQ==
7669+
axios@0.25.0, axios@0.27.2, axios@1.7.4, axios@^0.21.2, axios@^0.26.1, axios@^1.13.0, axios@^1.6.0, axios@^1.8.3:
7670+
version "1.13.5"
7671+
resolved "https://registry.npmjs.org/axios/-/axios-1.13.5.tgz#5e464688fa127e11a660a2c49441c009f6567a43"
7672+
integrity sha512-cz4ur7Vb0xS4/KUN0tPWe44eqxrIu31me+fbang3ijiNscE129POzipJJA6zniq2C/Z6sJCjMimjS8Lc/GAs8Q==
76737673
dependencies:
7674-
follow-redirects "^1.15.6"
7675-
form-data "^4.0.4"
7674+
follow-redirects "^1.15.11"
7675+
form-data "^4.0.5"
76767676
proxy-from-env "^1.1.0"
76777677

76787678
b4a@^1.6.4:
@@ -11934,7 +11934,7 @@ flux@^4.0.1:
1193411934
fbemitter "^3.0.0"
1193511935
fbjs "^3.0.1"
1193611936

11937-
follow-redirects@1.15.11, follow-redirects@^1.0.0, follow-redirects@^1.15.6:
11937+
follow-redirects@1.15.11, follow-redirects@^1.0.0, follow-redirects@^1.15.11:
1193811938
version "1.15.11"
1193911939
resolved "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.11.tgz#777d73d72a92f8ec4d2e410eb47352a56b8e8340"
1194011940
integrity sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==
@@ -11972,7 +11972,7 @@ forge-light@1.1.4:
1197211972
resolved "https://registry.npmjs.org/forge-light/-/forge-light-1.1.4.tgz"
1197311973
integrity sha512-Nr0xdu93LJawgBZVU/tC+A+4pbKqigdY5PRBz8CXNm4e5saAZIqU2Qe9+nVFtVO5TWCHSgvI0LaZZuatgE5J1g==
1197411974

11975-
form-data@^2.3.1, form-data@^4.0.0, form-data@^4.0.4, form-data@~4.0.4:
11975+
form-data@^2.3.1, form-data@^4.0.0, form-data@^4.0.4, form-data@^4.0.5, form-data@~4.0.4:
1197611976
version "4.0.4"
1197711977
resolved "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz"
1197811978
integrity sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==

0 commit comments

Comments
 (0)