Skip to content

Commit

Permalink
chore(sdk-coin-ada): bump CSL version and more
Browse files Browse the repository at this point in the history
Bump CSL version and expose signature in ADA txn wrapper

EA-621
  • Loading branch information
evanzbitgo committed Jun 22, 2023
1 parent c2a341a commit 4e94931
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 23 deletions.
4 changes: 2 additions & 2 deletions modules/sdk-coin-ada/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
"dependencies": {
"@bitgo/sdk-core": "^8.10.0",
"@bitgo/statics": "^17.0.1",
"@emurgo/cardano-serialization-lib-browser": "^10.2.0",
"@emurgo/cardano-serialization-lib-nodejs": "^10.2.0",
"@emurgo/cardano-serialization-lib-browser": "^11.4.0",
"@emurgo/cardano-serialization-lib-nodejs": "^11.4.0",
"bech32": "^2.0.0",
"bignumber.js": "^9.0.2",
"lodash": "^4.17.21",
Expand Down
8 changes: 8 additions & 0 deletions modules/sdk-coin-ada/src/lib/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,14 @@ export class Transaction extends BaseTransaction {

this._fee = txn.body().fee().to_str();
this.loadInputsAndOutputs();

if (this._transaction.witness_set().vkeys()) {
const vkeys = this._transaction.witness_set().vkeys()! as CardanoWasm.Vkeywitnesses;
for (let i = 0; i < vkeys.len(); i++) {
const vkey = vkeys.get(i);
this._signatures.push(vkey.signature().to_hex());
}
}
} catch (e) {
throw new InvalidTransactionError('unable to build transaction from raw');
}
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-coin-ada/src/lib/transactionBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ export abstract class TransactionBuilder extends BaseTransactionBuilder {
const vkey = CardanoWasm.Vkey.new(CardanoWasm.PublicKey.from_bytes(Buffer.from(signature.publicKey.pub, 'hex')));
const ed255Sig = CardanoWasm.Ed25519Signature.from_bytes(signature.signature);
vkeyWitnesses.add(CardanoWasm.Vkeywitness.new(vkey, ed255Sig));
this._transaction.signature.push(signature.signature.toString('hex'));
});
witnessSet.set_vkeys(vkeyWitnesses);

Expand Down
12 changes: 6 additions & 6 deletions modules/sdk-coin-ada/test/resources/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ export const rawTx = {
'a600818258203677e75c7ba699bfdc6cd57d42f246f86f63aefd76025006ac78313fad2bba2101018182583901c7b28bcea90d440b5455a6a02a27ca59b8696f067fc1967f47f933e79558e969caa9e57adcfc40b9907eb794363b590faf42fff48c38eb881a004d52e2021a00029ee5031a2faf0800048005a1581de0188fde65b1f9bd69b0edcc4e5a65fa93a13773090e1e2eef7a25cfdb1a0012e8c7',
unsignedStakingWithdrawTxHash: 'd4aa6878f9b810bd566aba4447eaf079ca86478175ef6d92f8d0e0fa5701d50e',
unsignedNewPledgeTx:
'84a50081825820985b52472d4dbc184a402df5b3cd0b67bb7e9b86ec27c20a0dc917898f64410c0001818258390085e399d9be12e5d7cef3bd44119d55432ae10ba8cfa07cede12370681fc30799b291432f1aade73a4e960e2d22511f1a797d7c47a569dba11b000000023633be28021a0002d509031a01d8063b04828a03581c76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681582034646b66ff5bac4a40c1b8558ee8a160524151f18f1f4b06450e8414bf562e311a05f5e1001a14904840d81e820f1864581de11fc30799b291432f1aade73a4e960e2d22511f1a797d7c47a569dba181581c76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681818301191770782172656c61796e6f6465312e6d79616461706f6f6c6e616d65726f636b732e636f6df683028200581c1fc30799b291432f1aade73a4e960e2d22511f1a797d7c47a569dba1581c76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681a10080f5f6',
'84a5008282582078e05b7941011b5275552d0e5074056273125e18aac81643bfc3de59abac0e8600825820ce6d283af95b4da0e4b86f20ddf25dfb0343a7402e35877307c1465bd7beeafa000181825839006d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec6d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec1a59682f00021a000f42400319ea6004828a03581c10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a058201cc18daee56cb67a5dfb860194cd1e878be38401f3990efd92e16c5f8f4d959c1a05f5e1001a1dcd6500d81e820314581de0a9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a16181581ca9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a161818301191770782572656c6179732d6e65772e63617264616e6f2d746573746e65742e696f686b6465762e696f827368747470733a2f2f72622e67792f697a747a71582010c343fe0f6c01291df08de0ddc8fcbc07bccb503c51ffc051785e783b8d2f4483028200581ca9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a161581c10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a0a10080f5f6',
unsignedNewPledgeTxBody:
'a50081825820985b52472d4dbc184a402df5b3cd0b67bb7e9b86ec27c20a0dc917898f64410c0001818258390085e399d9be12e5d7cef3bd44119d55432ae10ba8cfa07cede12370681fc30799b291432f1aade73a4e960e2d22511f1a797d7c47a569dba11b000000023633be28021a0002d509031a01d8063b04828a03581c76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681582034646b66ff5bac4a40c1b8558ee8a160524151f18f1f4b06450e8414bf562e311a05f5e1001a14904840d81e820f1864581de11fc30799b291432f1aade73a4e960e2d22511f1a797d7c47a569dba181581c76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681818301191770782172656c61796e6f6465312e6d79616461706f6f6c6e616d65726f636b732e636f6df683028200581c1fc30799b291432f1aade73a4e960e2d22511f1a797d7c47a569dba1581c76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681',
unsignedNewPledgeTxHash: 'dfa11367be1c45c0a2b98c350f7d6f04af08d123ec4d8ac9030676b75491f210',
'a5008282582078e05b7941011b5275552d0e5074056273125e18aac81643bfc3de59abac0e8600825820ce6d283af95b4da0e4b86f20ddf25dfb0343a7402e35877307c1465bd7beeafa000181825839006d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec6d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec1a59682f00021a000f42400319ea6004828a03581c10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a058201cc18daee56cb67a5dfb860194cd1e878be38401f3990efd92e16c5f8f4d959c1a05f5e1001a1dcd6500d81e820314581de0a9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a16181581ca9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a161818301191770782572656c6179732d6e65772e63617264616e6f2d746573746e65742e696f686b6465762e696f827368747470733a2f2f72622e67792f697a747a71582010c343fe0f6c01291df08de0ddc8fcbc07bccb503c51ffc051785e783b8d2f4483028200581ca9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a161581c10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a0',
unsignedNewPledgeTxHash: '2acd6d314772eaa046d0cca7ef0306599d9d8dd961ad38da69e5f5b4cefafd7d',
unsignedUpdatePledgeTx:
'84a500818258203b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b700018182583901eb0baa5e570cffbe2934db29df0b6a3d7c0430ee65d4c3a7ab2fefb91bc428e4720702ebd5dab4fb175324c192dc9bb76cc5da956e3c8dff0102182a030a04818a03581cf61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb49735820198890ad6c92e80fbdab554dda02da9fb49d001bbd96181f3e07f7a6ab0d06401a1dcd65001a1443fd00d81e820102581de13a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c49071182581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c4907118584001904d244c0a8000150b80d01200000a3852e8a00003473700384001904d2f650b80d01200000a3852e8a00003473700384001904d244c0a80001f683011904d26d7777772e746573742e7465737482026e7777772e74657374322e74657374827568747470733a2f2f7777772e746573742e746573745820914c57c1f12bbf4a82b12d977d4f274674856a11ed4b9b95bd70f5d41c5064a6a10080f5f6',
'84a5008282582078e05b7941011b5275552d0e5074056273125e18aac81643bfc3de59abac0e8600825820ce6d283af95b4da0e4b86f20ddf25dfb0343a7402e35877307c1465bd7beeafa000181825839006d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec6d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec1a59682f00021a000f42400319ea6004818a03581c10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a058201cc18daee56cb67a5dfb860194cd1e878be38401f3990efd92e16c5f8f4d959c1a05f5e1001a1dcd6500d81e820314581de0a9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a16181581ca9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a161818301191770782572656c6179732d6e65772e63617264616e6f2d746573746e65742e696f686b6465762e696f827368747470733a2f2f72622e67792f697a747a71582010c343fe0f6c01291df08de0ddc8fcbc07bccb503c51ffc051785e783b8d2f44a10080f5f6',
unsignedUpdatePledgeTxBody:
'a500818258203b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b700018182583901eb0baa5e570cffbe2934db29df0b6a3d7c0430ee65d4c3a7ab2fefb91bc428e4720702ebd5dab4fb175324c192dc9bb76cc5da956e3c8dff0102182a030a04818a03581cf61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb49735820198890ad6c92e80fbdab554dda02da9fb49d001bbd96181f3e07f7a6ab0d06401a1dcd65001a1443fd00d81e820102581de13a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c49071182581c122a946b9ad3d2ddf029d3a828f0468aece76895f15c9efbd69b4277581c3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c4907118584001904d244c0a8000150b80d01200000a3852e8a00003473700384001904d2f650b80d01200000a3852e8a00003473700384001904d244c0a80001f683011904d26d7777772e746573742e7465737482026e7777772e74657374322e74657374827568747470733a2f2f7777772e746573742e746573745820914c57c1f12bbf4a82b12d977d4f274674856a11ed4b9b95bd70f5d41c5064a6',
unsignedUpdatePledgeTxHash: 'e3b9a5657bf62609465a930c8359d774c73944973cfc5a104a0f0ed1e1e8db21',
'a5008282582078e05b7941011b5275552d0e5074056273125e18aac81643bfc3de59abac0e8600825820ce6d283af95b4da0e4b86f20ddf25dfb0343a7402e35877307c1465bd7beeafa000181825839006d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec6d57dea46753025b2c4e0fd9244df6a08fdd059dd1432af5eb7abbec1a59682f00021a000f42400319ea6004818a03581c10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a058201cc18daee56cb67a5dfb860194cd1e878be38401f3990efd92e16c5f8f4d959c1a05f5e1001a1dcd6500d81e820314581de0a9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a16181581ca9fd4c265da033970e0b22b06422e12b3479e8dbd35abc82d405a161818301191770782572656c6179732d6e65772e63617264616e6f2d746573746e65742e696f686b6465762e696f827368747470733a2f2f72622e67792f697a747a71582010c343fe0f6c01291df08de0ddc8fcbc07bccb503c51ffc051785e783b8d2f44',
unsignedUpdatePledgeTxHash: '671dfd283740d707e03a8ee5d21b3b9e3e50f57db68dc930606740ac7043151c',
pledgeNodeKeyPubkey: '1b400d60aaf34eaf6dcbab9bba46001a23497886cf11066f7846933d30e5ad3f',
pledgeNodeWitnessSignature:
'6c92508135cb060187a2706ade8154782867b1526e9615d06742be5c56f037ab85894c098c2ab07971133c0477baee92adf3527ad7cc816f13e1e4c361041206',
Expand Down
19 changes: 13 additions & 6 deletions modules/sdk-coin-ada/test/unit/stakingPledgeBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ describe('ADA Staking Pledge Transaction Builder', async () => {
const tx = (await txBuilder.build()) as Transaction;
should.equal(tx.type, TransactionType.StakingPledge);
const txData = tx.toJson();
txData.inputs.length.should.equal(1);
txData.inputs.length.should.equal(2);
txData.outputs.length.should.equal(1);
txData.certs.length.should.equal(2);
txData.certs[0].type.should.equal(3);
txData.certs[1].type.should.equal(1);
should.exist(txData.certs[1].poolKeyHash);
txData.certs[0].poolKeyHash!.should.equal('76044d3aa9caafbb213ae45f9a3f5ad3cc6c836f375ebbcfa5c83681');
txData.certs[0].poolKeyHash!.should.equal('10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a0');
txData.withdrawals.length.should.equal(0);
txData.witnesses.length.should.equal(0);

const fee = tx.getFee;
fee.should.equal('185609');
fee.should.equal('1000000');
tx.toBroadcastFormat().should.equal(rawTx.unsignedNewPledgeTx);
should.equal(tx.id, rawTx.unsignedNewPledgeTxHash);

Expand All @@ -42,17 +42,17 @@ describe('ADA Staking Pledge Transaction Builder', async () => {
const tx = (await txBuilder.build()) as Transaction;
should.equal(tx.type, TransactionType.StakingPledge);
const txData = tx.toJson();
txData.inputs.length.should.equal(1);
txData.inputs.length.should.equal(2);
txData.outputs.length.should.equal(1);
txData.certs.length.should.equal(1);
txData.certs[0].type.should.equal(3);
should.exist(txData.certs[0].poolKeyHash);
txData.certs[0].poolKeyHash!.should.equal('f61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb4973');
txData.certs[0].poolKeyHash!.should.equal('10324dc34187735de46f6260d94620cdcc819f7ed1f93e3fc58d06a0');
txData.withdrawals.length.should.equal(0);
txData.witnesses.length.should.equal(0);

const fee = tx.getFee;
fee.should.equal('42');
fee.should.equal('1000000');
tx.toBroadcastFormat().should.equal(rawTx.unsignedUpdatePledgeTx);
should.equal(tx.id, rawTx.unsignedUpdatePledgeTxHash);

Expand All @@ -67,7 +67,14 @@ describe('ADA Staking Pledge Transaction Builder', async () => {
txBuilder.initBuilder(prebuiltTx);
txBuilder.addNodeKeyWitness(rawTx.pledgeNodeKeyPubkey, rawTx.pledgeNodeWitnessSignature);
const tx = (await txBuilder.build()) as Transaction;
tx.signature.length.should.equal(1);
const txData = tx.toJson();
txData.witnesses.length.should.equal(1);

const rebuiltTx = new Transaction(coins.get('tada'));
rebuiltTx.fromRawTransaction(tx.toBroadcastFormat());
rebuiltTx.signature.length.should.equal(1);
rebuiltTx.toBroadcastFormat().should.equal(tx.toBroadcastFormat());
rebuiltTx.toBroadcastFormat().should.not.equal(rawTx.unsignedUpdatePledgeTx);
});
});
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1513,15 +1513,15 @@
resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed"
integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg==

"@emurgo/cardano-serialization-lib-browser@^10.2.0":
version "10.2.0"
resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-browser/-/cardano-serialization-lib-browser-10.2.0.tgz#5eb1d1b579072598e4911e5d8ae23f63e22e7b28"
integrity sha512-b4RrWtC5y8+bjKp9sFo8IWXg+xIatXoUq4YcqFDReDN6dpHRjLlOJv7h9Da6VA5GXvLQy6vOFuieAZJFGng9FQ==

"@emurgo/cardano-serialization-lib-nodejs@^10.2.0":
version "10.2.0"
resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-10.2.0.tgz#e76ee34fca434b5b0c95cf33ef61548d6845f79e"
integrity sha512-rRWBQcbQlMj4GS7gt6toxRzY9cjMfFBWYKWrfH+eEqUXSO+3blKKA3T/yra3khxU/8+EAY1T94uoUDvjkrpTzg==
"@emurgo/cardano-serialization-lib-browser@^11.4.0":
version "11.4.0"
resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-browser/-/cardano-serialization-lib-browser-11.4.0.tgz#53b5f26fac06e4f6bdef7a11eb57aebf403b1ef4"
integrity sha512-VWMvLRBFo7MAYh42zledURFs5BpMTWvkP4DzsLNbyJxZlwjDS+bPyehJVyGc116d2gq8NHFmANbfdeuK8ffJ7A==

"@emurgo/cardano-serialization-lib-nodejs@^11.4.0":
version "11.4.0"
resolved "https://registry.yarnpkg.com/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-11.4.0.tgz#2a47d1cbdbfe6ad96ea55ba03d6cbec90497ea9d"
integrity sha512-dMiofDcqv+IrAITCgWBZmsMLqwv2xImDsJDSrKiYYG1zRKaL8XfMOxx6S0WEnKVj5/343Q5FFURYcSu3iBRNMQ==

"@es-joy/jsdoccomment@^0.4.4":
version "0.4.4"
Expand Down

0 comments on commit 4e94931

Please sign in to comment.